
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>详情</title>
    <link rel="stylesheet" href="/${BasePath}/static/css/weui.css" media="all" />
    <link rel="stylesheet" href="/${BasePath}/static/css/layer.css" media="all" />
    <link rel="stylesheet" href="/${BasePath}/static/css/font-awesome.min.css" media="all" />
    <style type="text/css">
        body{padding-bottom: 65px}
        .content{background: #ddcba3;padding:10px;border-bottom-left-radius:6px;border-bottom-right-radius:6px}
        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }
        .img{width: 100%; height:auto;}
        .fixed-bottom{position: fixed;bottom: 0;left: 0;right: 0}
        .flex{padding: 0 10px}
        .panel{border-radius: 0;margin-bottom: 15px;background: #fff;}
        .title{padding: 10px 0; margin-bottom: 15px;position:relative}
        .name{background:#000;opacity:0.6;color:#fff;padding:5px 10px;margin-left: -10px;}
        .zan{margin-left:2em}
        .btn-block{display:block;width: 100%;margin:20px auto;background: #f1d005;height: 40px;line-height: 40px;color: #333;text-align: center;border-radius: 4px}
        .num{color:#ec1043 }
        .tr{float: right;}
        .text{margin-left:2em}
    </style>
    <script type="text/javascript" src="/${BasePath}/static/js/zepto.min.js"></script>
    <script type="text/javascript" src="/${BasePath}/static/js/vue.min.js"></script>
    <script type="text/javascript" src="/${BasePath}/static/js/axios.min.js"></script>
    <script type="text/javascript" src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
    <script type="text/javascript" src="/${BasePath}/static/js/layer.js"></script>
</head>
<body ontouchstart>
	
	<div id="app">
	    <div class="flex">
	        <div class="panel">
	        	<div class="content">
		            <div class="title">
		                <div><span class="name">{{number}}号 {{name}}</span><span class="zan">赞数:{{dianzan}}</span><span class="tr">排名:{{order}}名</span></div>
		            </div>
		            <img :src="pic" class="img">
		            <div class="describe">
		            	简介:{{describe}}
		            </div>
	            </div>
	            <a class="btn-block" v-on:click="dianzan1">点赞</a>
	            <a class="btn-block dzbtn" v-on:click="sendgift" style="display: none">赠送礼物</a>
	        </div>
	    </div>
	    <div class="swiper-container">
	        <img :src="activitpic" class="img">
	    </div>
	    <div class="weui-tabbar fixed-bottom">
	        <a :href="'/${BasePath}/free/playerList?activityid=' +activityid" class="weui-tabbar__item">
	            <span style="display: inline-block;position: relative;">
	                <i class="weui-tabbar__icon fa fa-home"></i>
	            </span>
	            <p class="weui-tabbar__label">首页</p>
	        </a>
	        <a :href="'/${BasePath}/free/toRankList?activityid=' +activityid" class="weui-tabbar__item">
	            <i class="weui-tabbar__icon fa fa-trophy"></i>
	            <p class="weui-tabbar__label">榜单</p>
	        </a>
	        <a :href="'/${BasePath}/free/toGift?activityid=' +activityid" class="weui-tabbar__item">
	            <i class="weui-tabbar__icon fa fa-gift"></i>
	            <p class="weui-tabbar__label">奖品</p>
	        </a>
	    </div>
	</div>
    
    <script type="text/javascript" src="/${BasePath}/static/js/common.js"></script>
    <script type="text/javascript">
    	var config = config();
	    var playerid = getUrlParam('playerid');
	    var activityid = getUrlParam('activityid');
	    var current = new Date().getTime();
	    var index;
    	var vm = new Vue({
    		el: '#app',
    		data:{
    			activitpic:'',
    			number: '',
    			name: '',
    			zan: '',
    			order: '',
    			pic: '',
    			activityid:'',
    			dianzan: '',
    			current: '',
    			endtime: '',
    			describe: '',
    			flag: '',
    			sts: ''
    		},
    		beforeCreate:function(){
    			index = layer.open({
		    	    type: 2
		    	    ,content: '加载中'
		    	});
    		},
    		created: function(){
    			var self = this;
    			self.current = current;
    			axios.get('/${BasePath}/free/getPlayerDetail',{
		    		params:{
		    			playerid: playerid
		    		}
		    	})
		    	.then(function(response){
		    		$("title").html(response.data.title);
		    		self.activitpic = response.data.activitpic;
		    		self.number = response.data.playerno;
		    		self.name = response.data.name;
		    		self.order = response.data.order;
		    		self.describe = response.data.declaration;
		    		self.dianzan = response.data.poll;
		    		self.sts = response.data.sts;
		    		self.endtime = new Date(response.data.endtime.replace("-", "/").replace("-", "/")).getTime();
		    		if(response.data.playerpcim){
		    			self.pic = response.data.playerpcim
		    		}
		    		else{
		    			self.pic = response.data.playerpicbig;
		    		}
		    		self.activityid = response.data.activityid;
		    		self.flag = response.data.flag;
		    		if(self.sts == 'Y' && self.flag == 'Y' && self.current<self.endtime){
		    			$('.dzbtn').show()
		    		}
		    		wx.config({
		    		    appId: config.appId, // 必填，公众号的唯一标识
		    		    timestamp: config.timestamp, // 必填，生成签名的时间戳
		    		    nonceStr: config.nonceStr, // 必填，生成签名的随机串
		    		    signature: config.signature,// 必填，签名
		    		    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'] // 必填，需要使用的JS接口列表
		    		});
		    	    wx.ready(function(){
    		    	    wx.onMenuShareTimeline({ 
    		    	        title: response.data.title, // 分享标题
    		    	        desc: '我家萌娃' + response.data.playerno + '号' + response.data.name + '正在参加' + response.data.title, // 分享描述
    		    	        link: window.location.href.split("#")[0], // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
    		    	        imgUrl: response.data.playerpicbig, // 分享图标
    		    	        success: function () {
    		    	          // 设置成功
    		    	        }
    		    	    })
    		    	    wx.onMenuShareAppMessage({ 
    		    	        title: response.data.title, // 分享标题
    		    	        desc: '我家萌娃' + response.data.playerno + '号' + response.data.name + '正在参加' + response.data.title  + '活动,快来点赞吧', // 分享描述
    		    	        link: window.location.href.split("#")[0], // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
    		    	        imgUrl: response.data.playerpicbig, // 分享图标
    		    	        success: function () {
    		    	          // 设置成功
    		    	        }
    		    	    })
		    	    })
		    	    layer.close(index);
		    	})
		    	.catch(function(error){
		    		console.log(error);
		    	})
    		},
    		methods:{
    			dianzan1:function(){
    				var self = this;
    				if(self.sts == "Y"){
	    				$.ajax({
	    					type: 'post',
	    					url: '/${BasePath}/free/userThumb',
	    					data:{
	    						playerid: playerid,
	    						activityid: activityid,
	    		    			openid: openid
	    					},
	    					success:function(res){
	    						if(res){
	    							if(res.code == "0001"){
	    								layer.open({
	    								    content: res.msg
	    								    ,skin: 'msg'
	    								    ,time: 2 
	    								});
	    								
	    							}
	    							if(res.code == "0002"){
	    								layer.open({
	    								    content: res.msg
	    								    ,skin: 'msg'
	    								    ,time: 2 
	    								});
	    							}
	    							if(res.code == "0003"){
	    								layer.open({
	    								    content: res.msg
	    								    ,skin: 'msg'
	    								    ,time: 2 
	    								});
	    								self.dianzan = self.dianzan + 1
	    							}
	    							if(res.code == "0004"){
	    								layer.open({
	    								    content: res.msg
	    								    ,skin: 'msg'
	    								    ,time: 2 
	    								});
	    							}
	    							if(res.code == "0005"){
	    								layer.open({
	    								    content: res.msg
	    								    ,skin: 'msg'
	    								    ,time: 2 
	    								});
	    							}
	    						}
	    					}
	    				})
    				}
    				else{
    					layer.open({
						    content: '您当前涉嫌刷票，请遵守活动规则'
						    ,skin: 'msg'
						    ,time: 2 
						});
    				}
    			},
    			sendgift:function(){
    				window.location.href = "/${BasePath}/free/toUserSendGift?activityid=" + activityid + "&playerid=" + playerid
    			}
    		}
    	})
    </script>
</body>
</html>
